using System.Numerics;
using NUnit.Framework;
using ProjectEuler.Core.Helpers;

namespace ProjectEuler.Core
{
    public class Problem53 : IProjectEulerProblem
    {
        protected long NumberOfValuesGreaterThan(int max)
        {
            var vals = 0;
            for(int n=1;n<=100;n++)
            {
                for(int r=1;r<=n;r++)
                {
                    if(C(n,r) > max)
                    {
                        vals++;
                    }
                }
            }
            return vals;
        }

        protected BigInteger C(int n, int r)
        {
            return MathHelper.Factorial(n)/(MathHelper.Factorial(r)*MathHelper.Factorial(n - r));
        }

        public int Number
        {
            get { return 53; }
        }

        public string Description
        {
            get { return "How many values are greater than one-million?"; }
        }

        public string Answer
        {
            get { return NumberOfValuesGreaterThan(1000000).ToString(); }
        }
    }

    [TestFixture]
    public class Problem53Tests : Problem53
    {
        [Test]
        public void Then_5_C_3_should_be_10()
        {
            Assert.AreEqual(10, C(5, 3));
        }
    }
}